#include<bits/stdc++.h>
using namespace std;
struct stu
{
	string name;
	int a,b,c,sum=0;
	char bo1,bo2;
}s[1000];
int main()
{
	int n,sm=0,num,i,mx=-0x3f3f3f3f;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>s[i].name>>s[i].a>>s[i].b>>s[i].bo1>>s[i].bo2>>s[i].c;
		if(s[i].a>80&&s[i].c>=1)
			s[i].sum+=8000;
		if(s[i].a>85&&s[i].b>80)
			s[i].sum+=4000;
		if(s[i].a>90)
			s[i].sum+=2000;
		if(s[i].a>85&&s[i].bo2=='Y')
			s[i].sum+=1000;
		if(s[i].b>80&&s[i].bo1=='Y')
			s[i].sum+=850;
		sm+=s[i].sum;
		if(mx<s[i].sum)
			mx=s[i].sum,num=i; 
	}
	cout<<s[num].name<<endl<<s[num].sum<<endl<<sm;
    return 0;
}
